<template>
  <div class="headers">
    <br/>
    <!--banner以及保证金-->
    <div class="circul">
      <img src="../../assets/img/join-banner.png">
      <div class="getcenter">
        <p class="getmoney">200000</p>
        <span class="getpromise">已缴纳保证金(元)</span>
      </div>
    </div>

    <!--购物消费趋势-->
    <div class="circul">
      <div class="title">
        <div class="shopping">购物消费趋势</div>
        <div class="rightTitle">
          <div class="getyear" @click="doShowYear">{{getyear}}年
            <img src="../../../static/image/joinIn/down.png" class="images">
          </div>

          <div class="getmonth" @click="doshow">
            {{getmonth}}
            <img src="../../../static/image/joinIn/down.png" class="images">
          </div>

            <van-actionsheet v-model="showYear" @select=" onSelectYear" style="height: 40%;">
              <van-picker show-toolbar :columns="columns" @confirm="onConfirmYear"  @cancel="onCancelYear"/>
            </van-actionsheet>

          <van-actionsheet v-model="showMonth" @select="onSelectMonth" style="height: 40%;">
            <van-picker show-toolbar :columns="monthcolumns" @confirm="onConfirmMonth"  @cancel="onCancelMonth"/>
          </van-actionsheet>
        </div>
      </div>
      <div class="trend">
        <div id="myChart" style="width:100%;height:300px"></div>
      </div>
    </div>

    <!--本月消费分析-->
    <div class="circul" style="margin-top: 12px">
      <span class="shopping">本月消费分析</span>
      <div class="cost">
        <van-row>
          <van-col span="10" offset="1">
            <div class="box all-consume">
              <p class="consume">总消费(元)</p>
              <p class="font-center">12834.00</p>
            </div>
          </van-col>
          <van-col span="10" offset="2">
            <div class="box eff-consume">
              <p class="consume">有效消费(元)</p>
              <p class="font-center">12834.00</p>
            </div>
          </van-col>
          <van-col span="10" offset="1">
            <div class="box success-count">
              <p class="consume">成功订单(笔)</p>
              <p class="font-center">128340</p>
            </div>
          </van-col>
          <van-col span="10" offset="2">
            <div class="box refund-money">
              <p class="consume">退款(元)</p>
              <p class="font-center">1595545.00</p>
            </div>
          </van-col>
        </van-row>
      </div>
    </div>
    <!--总消费分析-->
    <div class="circul" style="margin-top: 12px">
      <span class="shopping">总消费分析</span>
      <div class="cost">
        <van-row>
          <van-col span="10" offset="1">
            <div class="box all-consume">
              <p class="consume">总消费(元)</p>
              <p class="font-center">12834.00</p>
            </div>
          </van-col>
          <van-col span="10" offset="2">
            <div class="box eff-consume">
              <p class="consume">有效消费(元)</p>
              <p class="font-center">12834.00</p>
            </div>
          </van-col>
          <van-col span="10" offset="1">
            <div class="box success-count">
              <p class="consume">成功订单(笔)</p>
              <p class="font-center">128340</p>
            </div>
          </van-col>
          <van-col span="10" offset="2">
            <div class="box refund-money">
              <p class="consume">退款(元)</p>
              <p class="font-center">1595545.00</p>
            </div>
          </van-col>
        </van-row>
      </div>
    </div>



    <div class="agree-aticle">
      <p>
        <span style="color: #333333">点击了解</span>
        <router-link to="/contract">
          <span style="color: red">《纳品网加盟合作服务协议》</span>
        </router-link>
      </p>
    </div>
    <!--按钮-->
    <van-button style="background-color: #FF7878;border: 1px solid #FF7878;margin-top: 10px" type="primary"
                size="large">申请退还押金
    </van-button>
  </div>
</template>

<script>
  import echarts from 'echarts'
  import {Button, Actionsheet, Picker} from 'vant';

  export default {
    name: "joinBill",
    components: {
      [Button.name]: Button,
      [Actionsheet.name]: Actionsheet,
      [Picker.name]: Picker,
    },
    data() {
      return {
        showMonth: false,
        showYear:false,
        columns: ['2019', '2018', '2017', '2016', '2015'],
        getyear: '2019',
        getmonth: '上半年',
        monthcolumns:['上半年','下半年'],
        isyear: true
      }
    },
    mounted() {
      /*ECharts图表*/
      var myChart = echarts.init(document.getElementById('myChart'));
      myChart.setOption({
        color: ['#ffbfc9'],
        tooltip: {
          trigger: 'axis',
          axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['一月', '二月', '三月', '四月', '五月', '六月'],
            axisTick: {
              alignWithLabel: true
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            show: false
          }
        ],
        series: [
          {
            name: '',
            type: 'bar',
            barWidth: '60%',
            data: [10, 52, 200, 334, 390, 330]
          }
        ]
      })

    },
    methods: {
      onSelectYear(item) {
        // 点击选项时默认不会关闭菜单，可以手动关闭
        this.showYear = false;
        // Toast(item.name);
      },

      onSelectMonth(item){
        this.showMonth = false;
      },

      doShowYear(){
        this.showYear=true;
      },
      doshow() {
        // this.isyear = false;
        // this.column = this.monthcolumns;
        this.showMonth = true;
      },
      onConfirmYear(value, index) {
        this.showYear = false;
        this.getyear = value;
        console.log(`当前值2：${value}, 当前索引：${index}`);
      },

      onCancelYear(){
        this.showYear = false
      },

      onConfirmMonth(value, index) {
        this.showMonth = false;
        this.getmonth = value;
        console.log(`当前值2：${value}, 当前索引：${index}`);
      },

      onCancelMonth(){
        this.showMonth = false
      },
    }
  }
</script>

<style scoped>
  .headers {
    background-color: #f3f3f3;
    height: 100%;
  }

  .circul {
    border-radius: 8px;
    background-color: #FFFFFF;
    margin: 12px auto 0 auto;
    width: 94%;
  }

  .title {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
  }

  .rightTitle {
    display: flex;
    justify-content: space-between;
    line-height: 40px;
    margin-right: 8px;
  }

  .images {
    width: 11px;
    height: 6px;
    line-height: 40px;
  }

  .getmoney {
    color: #333333;
    font-size: 24px;
  }

  .getcenter {
    text-align: center;
    margin-top: -5px;
    height: 70px;
  }

  .getpromise {
    color: #666666;
    margin: 0 auto;
  }

  .shopping {
    font-family: PingFang-SC-Regular;
    font-weight: bold;
    color: rgba(51, 51, 51, 1);
    line-height: 40px;
    font-size: 16px;
    margin-left: 15px;
  }

  .trend {
    margin-top: 10px;
  }

  .box {
    padding-top: 10px;
  }

  .cost .box {
    height: 28vw;
  }

  .all-consume {
    background-image: url("../../assets/img/join-red.png");
    -webkit-background-size: 100%;
    background-size: 100%;
    background-repeat: no-repeat;
  }

  .eff-consume {
    background-image: url("../../assets/img/join-blue.png");
    -webkit-background-size: 100%;
    background-size: 100%;
    background-repeat: no-repeat;
  }

  .success-count {
    background-image: url("../../assets/img/join-orange.png");
    -webkit-background-size: 100%;
    background-size: 100%;
    background-repeat: no-repeat;
  }

  .refund-money {
    background-image: url("../../assets/img/join-purple.png");
    -webkit-background-size: 100%;
    background-size: 100%;
    background-repeat: no-repeat;
  }

  .font-center {
    color: #FFFFFF;
    text-align: center;
    margin-top: 5px;
    font-size: 18px;
  }

  .consume {
    color: #FFFFFF;
    margin-left: 15px;
    font-size: 14px;
  }

  .agree-aticle {
    margin-top: 20px;
    margin-left: 10px;
  }

  .getyear {
    line-height: 40px;
    margin-right: 20px;
    color: #FF3C64;
  }

  .getmonth {
    line-height: 40px;
    color: #FF3C64;
  }

</style>
